package com.zzty.taskapp.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zzty.taskapp.service.QuestionService;
import com.zzty.taskapp.service.TeamExamService;
import com.zzty.taskapp.service.TeamExamTransationService;
import com.zzty.taskapp.serviceImpl.QuestionServiceImpl;
import com.zzty.taskapp.serviceImpl.TeamExamServiceImpl;
import com.zzty.taskapp.serviceImpl.TeamExamTransationServiceImpl;

/**
 * Servlet implementation class TeamExamServlet
 */
@WebServlet(name = "TeamExamServlet", urlPatterns = "/TeamExamServlet")
public class TeamExamServlet extends HttpServlet {
	TeamExamService texi = new TeamExamServiceImpl();
	QuestionService qsi = new QuestionServiceImpl();
	TeamExamTransationService tets=new TeamExamTransationServiceImpl(); 
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public TeamExamServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
//		request.setCharacterEncoding("utf-8");
//		response.setCharacterEncoding("utf-8");
//		TeamExamServiceImpl texi = new TeamExamServiceImpl();
//		QuestionServiceImpl qsi = new QuestionServiceImpl();
//		String Date = request.getParameter("Date");
//		String clazz = request.getParameter("clazz");
//		// response.getWriter().print(texi.getQuestion(Date, clazz));
//		String[] array = texi.getQuestionID(Date, clazz);
//		String s = qsi.getQuestion(array);
//		PrintWriter out = response.getWriter();
//		out.print(s);
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		String s = searchQuestion(request, response);
		
	}

	protected String searchQuestion(HttpServletRequest request, HttpServletResponse response) {
//		String date = request.getParameter("date");
//		String clazz = request.getParameter("clazz");
//		
//		String[] array = texi.getQuestionID(date, clazz);
//		String s = qsi.getQuestion(array);
		return null;

	}
	protected String searchStartTime(int exameid, String userids, int userid){
		String startTime=tets.searchStateToStartTime(exameid, userids, userid);
		return startTime;
	}
	

}
